<template>
    <div id="agreement" class='agreement'>
        <div class="title">{{ agreementTitle }}</div>
        <div class="content">
            <div v-for="(item, index) in contentList" :class="['items', indexList.includes(index) ? 'mt-30' : '']"
                :key="item">
                {{ item }}
            </div>
        </div>
        <div class="party-a">
            <div class="ft">
                <span>甲方：方田教育</span>
            </div>
            <div class="date">
                <span>日期：</span>
                <span>{{ currentDay[0] }}</span>
                <span>年</span>
                <span>{{ currentDay[1] }}</span>
                <span>月</span>
                <span>{{ currentDay[2].split(" ")[0] }}</span>
                <span>日</span>
            </div>
            <img src="../../assets/img/agreement/seal.png" alt="" srcset="" />
        </div>
        <div class="party-b">
            <div class="ft">
                <div class="sign">
                    <span>乙方：</span>
                    <!-- v-show="!signature" -->
                    <!-- <span class="start-sign" v-show="!signature"></span> -->
                    <img :src="formInfo.signature" class="sign-img" alt="暂无图片" crossOrigin="anonymous" />
                </div>
            </div>
            <div class="date">
                <span>日期：</span>
                <span>{{ formInfo.joinTrainingTime[0] }}</span>
                <span>年</span>
                <span>{{ formInfo.joinTrainingTime[1] }}</span>
                <span>月</span>
                <span>{{ formInfo.joinTrainingTime[2] }}</span>
                <span>日</span>
            </div>
        </div>

        <van-back-top>
            <template #default>
                <img src="../../assets/img/toTop.png" class="back-to-top-img" alt="" srcset="" />
            </template>
        </van-back-top>
    </div>

</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';

const clickStatus = JSON.parse(localStorage.getItem('clickStatus'));

const currentDay = ref(clickStatus.currentDay?.split("-") || "")

onMounted(() => {

});

// 签名照片
const signature = ref<string>('');
const formInfo = ref({
    name: clickStatus.userName,//姓名
    phoneNum: clickStatus.phone,//手机号
    addr: clickStatus.certificateType,//培训地址
    id: clickStatus.certificateNumber,//用户身份证
    picker: clickStatus.trainingTime,//培训日期
    signature: clickStatus.agreementUrl,//签字图片
    joinTrainingTime: clickStatus.agreementTime?.split("-") || "",//签字日期
});
const agreementTitle = ref<string>('应届生三方协议签约意向确认书');
const indexList = ref<number[]>([6, 9, 11, 13, 17, 21]);
const salary = ref<string | number>('10');
const internshipSalary = ref<string | number>('90'); //实习期
const probationPeriodSalary = ref<string | number>('3150'); //试用期
const regularSalary = ref<string | number>(3500); //正式工
const lessonFee = ref<string | number>(300);
const date = ref<string[]>(['2024', '10', '01']);
const contentList = ref<string[]>([
    `尊敬的${formInfo.value.name}同学：`,
    `您好！`,
    `我们很开心通知您通过了方田教育的培训考核，正式进入三方签约环节，为了明确您的签约意向，我们向您发送此确认书。以下是签约意向的具体内容：`,
    `1. 职位及职责：您将担任教师岗，主要负责教学工工作。`,
    `2. 薪资结构：乙方入职甲方，转正后首年年综合收入原则上不低于人民币${salary.value}万元/年。乙方入职后的薪酬结构原则上为岗位工资+课时费+综合福利。其中，乙方实习期岗位工资标准为人民币${internshipSalary.value}元/天，试用期岗位工资标准为人民币${probationPeriodSalary.value}元/月，转正后岗位工资标准为人民币${regularSalary.value}元/月。课时费标准为${lessonFee.value}元/课起，具体课时费将根据乙方每月实际课时数量和考核结果计算并发放。`,
    '3. 三方协议：我们将与您签订应届生三方协议，确保您的学业和实习安排符合学校规定，同时满足公司的人才需求。',
    '为了确认您的签约意向，请您在收到本确认书后三个工作日内回复，并按照以下指示操作：',
    `- 如果您接受我们的工作邀请并愿意签订三方协议，请签署本确认书的副本，并将其返回给我们，我们将在${getFutureDate(3)}日主动联系您沟通签约细节。`,
    `- 如果您在三个工作日之内未给出明确答复，则视为放弃此份offer，公司将不再为您保留此岗位。 请注意，本确认书的签署并不代表最终的就业合同，所有条款将在正式的三方协议中详细列明。 我们期待您的积极回应，并希望能够与您一起开启美好的职业旅程。`,
    `  此致`,
    `敬礼`,
]);
function getFutureDate(daysAhead: any) {
    // 获取当前日期
    const newDays = new Date(clickStatus.agreementTime);
    const today = newDays;
    // 计算未来几天的日期
    const futureDate = new Date(today);
    futureDate.setDate(today.getDate() + daysAhead);
    // 格式化日期
    const year = futureDate.getFullYear();
    const month = String(futureDate.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要加1
    const day = String(futureDate.getDate()).padStart(2, '0');
    return `${year}年${month}月${day}日`;
}
</script>

<style lang="less" scoped>
#agreement {
    width: 100vw;
    //overflow: auto;
    padding: 17px;
    box-sizing: border-box;
    background: #fff;
    color: #333;
    padding-top: 60px;
}

.title {
    width: 100%;
    height: 40px;
    opacity: 1;
    font-size: 18px;
    font-weight: normal;
    line-height: 25px;
    text-align: center;
    letter-spacing: 0em;
    font-variation-settings: 'opsz' auto;
    color: #212121;
}

.content {
    .items {
        margin-top: 5px;
    }
}

.mt-30 {
    margin-top: 20px !important;
}

.signature {
    position: fixed;
    top: v-bind(top);
    left: v-bind(left);
    width: 100vh;
    height: 100vw;
    transform: rotate(90deg);
    background: #fff;
    transform-origin: center;
    display: flex;
    flex-direction: column;
    flex-flow: column-reverse;
    padding: 20px;
    z-index: 999;
}

.btn-area {
    position: absolute;
    top: 20px;
    right: 75px;
    display: flex;

    .btns {
        line-height: 44px;
        text-align: center;
        color: #fff;
        width: 111px;
        height: 44px;
        background: #209ee4;
        border-radius: 5px;

        &:nth-child(1) {
            margin-right: 20px;
            color: #f56c56;
            background: #f5f7fb;
            border: 1px solid #b3c0c8;
        }
    }
}

.back {
    position: absolute;
    top: 30px;
    left: 30px;
    display: flex;
    color: #333;
    font-size: 16px;
    display: flex;
    align-items: center;

    span {
        margin-left: 10px;
    }
}

.sign {
    display: flex;
    height: 70px;
    align-items: center;

    .start-sign {
        // color: #409eff;
        width: 173px;
        height: 30px;
        background: #f4f6f8;
        border-radius: 5px;
    }

    .sign-img {
        margin-left: 20px;
        width: 130px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

.party-a {
    // margin: 24px 0;
    margin-top: 24px;
    line-height: 26px;
    position: relative;

    img {
        width: 70px;
        position: absolute;
        left: 30%;
        top: -10%;
    }
}

.date {
    span {
        &:nth-child(2n) {
            text-decoration: underline;
            margin: 0 5px;
        }
    }
}

.sub-btn {
    width: 95%;
    height: 44px;
    background: #209ee4;
    border-radius: 5px;
    line-height: 44px;
    text-align: center;
    color: #fff;
    font-size: 14px;
    margin: 0 auto;
    margin-bottom: 10px;
    margin-top: 20px;

    span {
        font-size: 14px !important;
    }
}
</style>